package com.czy.owner.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.czy.owner.R;
import com.czy.owner.db.SearchTable;

import java.util.List;

/**
 * Created by King on 2016/7/22 0022.
 */
public class SearchHistoryAdapter extends BaseRecyclerAdapter<SearchTable,SearchHistoryAdapter.SearchHistoryViewHolder> {
    public SearchHistoryAdapter(Context context, List<SearchTable> data) {
        super(context, data);
    }

    @Override
    public SearchHistoryViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new SearchHistoryViewHolder(layoutInflater.inflate(R.layout.item_search_history_recycler,parent,false));
    }

    @Override
    public void onBindViewHolder(SearchHistoryViewHolder holder, int position) {
        super.onBindViewHolder(holder, position);
        holder.bindData(data.get(position));
    }

    public class  SearchHistoryViewHolder extends BaseRecyclerAdapter.ViewHolder{
        public TextView tvKeyword;
        public SearchHistoryViewHolder(View itemView) {
            super(itemView);
            tvKeyword = (TextView)itemView.findViewById(R.id.tv_search_history_item_keyword);
        }
        public void bindData(SearchTable searchTable){
            tvKeyword.setText(searchTable.getKeyWord());
        }
    }
}
